<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>

<%@ include file="../layout/header.jsp"%>

<!-- 主体部分开始 -->
<div class="container" style="margin-top: 10px;">
	<div class="row">
		<h1>新增用户</h1>
		<form action="${ctx}/user.do?type=add" method="post"
			onsubmit="return validate();">
			<div class="form-group">
				<label for="loginName">登录名称</label><span style="color: red;">&nbsp;&nbsp;${msg}</span>
				<input type="text" class="form-control" id="loginName"
					name="loginName" placeholder="登录名称">
			</div>
			<div class="form-group">
				<label for="realName">真实名称</label> <input type="text"
					class="form-control" id="realName" name="realName"
					placeholder="真实姓名">
			</div>
			<div class="form-group">
				<label>性别</label> <select name="gender" class="form-control">
					<option value="0">女</option>
					<option value="1">男</option>
				</select>
			</div>
			<div class="form-group">
				<label for="email">邮箱</label> <input type="email"
					class="form-control" id="email" name="email" placeholder="邮箱">
			</div>
			<div class="form-group">
				<label for="phone">电话</label> <input type="text"
					class="form-control" id="phone" name="phone" placeholder="电话">
			</div>
			<div class="form-group">
				<label>所属角色</label> 
				<select name="roleId" class="form-control">
					<c:forEach items="${roles}" var="obj">
						<option value="${obj.id}">${obj.description}</option>
					</c:forEach>
				</select>
			</div>
			<button type="submit" class="btn btn-default">确定</button>
			<a type="button" href="${ctx}/user.do?type=list"
				class="btn btn-success">返回</a>
		</form>
	</div>
</div>
<!-- 主体部分结束 -->

<%@ include file="../layout/footer.jsp"%>

<script type="text/javascript">
	function validate() {
		var flag = true;
		var loginName = $("#loginName").val();
		var email = $("#email").val();
		var phone = $("#phone").val();
		if (loginName == null || loginName.length == 0) {
			flag = false;
			alert("登录名称不能为空！");
		}
		if (email == null || email.length == 0) {
			flag = false;
			alert("邮件地址不能为空！");
		}
		if (phone == null || phone.length == 0) {
			flag = false;
			alert("电话号码不能为空！");
		}
		return flag;
	}
</script>




















